package 队列;

import java.util.*;

public class 优先队列的用法 {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();
        Integer[] a = new Integer[n];

        for (int i = 0; i < n; i++) {
            a[i] = scanner.nextInt();
        }

        PriorityQueue<Integer> b = new PriorityQueue<>(Arrays.asList(a));

        b.add(22);
        System.out.println(b);
        System.out.println(b.remove());
        System.out.println(b);
        System.out.println(Collections.max(b));
        System.out.println(b);
    }
}
